# -*- coding: utf-8 -*-
# owner: shenyi

class BaseStrategy:
    pass

class ExcludeInstanceFamilyStrategy(BaseStrategy):

    @staticmethod
    async def exclude(instance_type_id, exclude_families):
        
        if isinstance(exclude_families, str):
            exclude_families_list = exclude_families.split(',')
        else:
            exclude_families_list = exclude_families
            
        for farmily in exclude_families_list:
            if instance_type_id.startswith(farmily):
                return True
        return False


class CpuStrategy(BaseStrategy):

    @staticmethod
    async def filter(cpu, mini_cpu):
        
        if mini_cpu > cpu:
            return True
        
        return False
    
class MemoryStrategy(BaseStrategy):
    @staticmethod
    async def filter(memory, mini_memory):
        
        if mini_memory > memory:
            return True
        
        return False